package com.huiyujinrong.qiangdanbao.activity.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.huiyujinrong.qiangdanbao.R;
import com.huiyujinrong.qiangdanbao.adapter.SportAdapter;
import com.huiyujinrong.qiangdanbao.bean.SportHeaderBean;
import com.huiyujinrong.qiangdanbao.bean.SportItemBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 精彩活动
 * Created by ZQXQ-Developer on 2017/6/29.
 */

public class SplendidActivity extends AppCompatActivity {
    @BindView(R.id.toolbar_Back)
    RelativeLayout back;
    @BindView(R.id.toolbar_Title)
    TextView tvTitle;


    @BindView(R.id.recyclerView_selend)
    RecyclerView recyclerView;

    SportAdapter adapter;
    List<Object> data = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ui_selend_activity);
        ButterKnife.bind(this);
        tvTitle.setText("精彩活动");
        back.setVisibility(View.VISIBLE);

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new SportAdapter(this, data);
        recyclerView.setAdapter(adapter);

        adapter.setmItemClickListener(new SportAdapter.OnItemClickListener() {
            @Override
            public void onHeaderClickListener(View view) {

            }

            @Override
            public void onItemClickListener(View pos) {
                Toast.makeText(SplendidActivity.this, "跳转到详情：", Toast.LENGTH_SHORT).show();
            }
        });
        initData();
    }

    private void initData() {
        SportHeaderBean headerBean = new SportHeaderBean(1, "http://img3.imgtn.bdimg.com/it/u=524208507,12616758&fm=206&gp=0.jpg");
        data.add(headerBean);


        SportItemBean itemBean = new SportItemBean("http://img2.imgtn.bdimg.com/it/u=2850936076,2080165544&fm=206&gp=0.jpg", "我是标题0号，请给我0票");
        SportItemBean itemBean1 = new SportItemBean("http://img4.imgtn.bdimg.com/it/u=4141168524,78676102&fm=21&gp=0.jpg", "我是标题1号，请给我一票");
        SportItemBean itemBean2 = new SportItemBean("http://img3.imgtn.bdimg.com/it/u=524208507,12616758&fm=206&gp=0.jpg", "我是标题2号，请给我2票");
        SportItemBean itemBean3 = new SportItemBean("http://img5.imgtn.bdimg.com/it/u=1467751238,3257336851&fm=11&gp=0.jpg", "我是标题3号，请给我3票");
        SportItemBean itemBean4 = new SportItemBean("http://img3.imgtn.bdimg.com/it/u=698582197,4250615262&fm=206&gp=0.jpg", "我是标题4号，请给我4票");
        SportItemBean itemBean5 = new SportItemBean("http://img2.imgtn.bdimg.com/it/u=2850936076,2080165544&fm=206&gp=0.jpg", "我是标题5号，请给我5票");
        SportItemBean itemBean6 = new SportItemBean("http://img3.imgtn.bdimg.com/it/u=524208507,12616758&fm=206&gp=0.jpg", "我是标题6号，请给我6票");
        SportItemBean itemBean7 = new SportItemBean("http://img3.imgtn.bdimg.com/it/u=2566161363,1140447270&fm=206&gp=0.jpg", "我是标题7号，请给我7票");
        SportItemBean itemBean8 = new SportItemBean("http://img3.imgtn.bdimg.com/it/u=698582197,4250615262&fm=206&gp=0.jpg", "我是标题8号，请给我8票");
        SportItemBean itemBean9 = new SportItemBean("http://img3.imgtn.bdimg.com/it/u=698582197,4250615262&fm=206&gp=0.jpg", "我是标题8号，请给我8票");
        data.add(itemBean);
        data.add(itemBean1);
        data.add(itemBean2);
        data.add(itemBean3);
        data.add(itemBean4);
        data.add(itemBean5);
        data.add(itemBean6);
        data.add(itemBean7);
        data.add(itemBean8);
        data.add(itemBean9);
        adapter.notifyDataSetChanged();
    }

    @OnClick({R.id.toolbar_Back})
    public void onClicks(View v) {
        switch (v.getId()) {
            case R.id.toolbar_Back:
                finish();
                break;
        }
    }
}
